package poker;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SettingsGUI extends JFrame implements ActionListener {
	private static HoofdSchermGUI hs;
	
	private JButton ok = new JButton("Ok");
	private JButton cancel = new JButton("Cancel");
	private JButton apply = new JButton("Apply");
	private MyTabbedPanel mt = new MyTabbedPanel();
	public SettingsGUI(HoofdSchermGUI hs)
	{
		this.hs = hs;
		mt.addTab("Personal", new PersonalSettingsGUI(this) );
		mt.addTab("Kaart", new SettingsKaartAchtergrondGUI(this) );
		mt.addTab("Server", new ServerSettingsGUI(this) );
		
		
		JPanel theButtons = new JPanel();
		theButtons.add(ok);
		theButtons.add(cancel);
		theButtons.add(apply);
		ok.addActionListener(this);
		cancel.addActionListener(this);
		apply.addActionListener(this);
		
		Container c = getContentPane();
		
		java.awt.Dimension ss = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
		int x = (int) ( (ss.getWidth() / 2 ) - 150 );
		int y = (int) ( (ss.getHeight() / 2 ) - 150 );
	
		setLocation( x, y );
		
		c.add(new PaddingGUI(5), BorderLayout.NORTH);
		c.add(theButtons, BorderLayout.SOUTH);
		c.add(new PaddingGUI(5), BorderLayout.WEST);
		c.add(new PaddingGUI(5), BorderLayout.EAST);
		c.add(mt, BorderLayout.CENTER);
		
		setSize(500, 300);
		setResizable(false);
		setTitle("Settings");
		setVisible(true);
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		validate();
	}
	
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource() == ok)
		{
			mt.activeTab.content.ok();
			dispose();
		}
		if(e.getSource() == cancel)
		{
			dispose();
		}
		if(e.getSource() == apply)
		{
			mt.activeTab.content.ok();
		}
	}
	
	public void remove()
	{
		dispose();
	}
	
	public static HoofdSchermGUI getHoofdScherm()
	{
		return hs;
	}
}
